home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Utilitaires divers / Images / Image 1.37 ƒ / Macros / Line Plots->Data < prev    next >
Encoding:
Text File  |  1991-03-25  |  2.3 KB  |  107 lines  |  [TEXT/MSWD]

  1. macro 'Convert Line Plot to Points [C]';
  2. {
  3. Requires a binary image conatining a black plot on a white
  4. background. Select the plot before running this macro. It may be
  5. necessary to increase Max Measurements in Options.
  6. }
  7. var
  8.   left,top,width,height,i:integer;
  9. begin
  10.   GetRoi(left,top,width,height);
  11.   if width=0 then begin
  12.     PutMessage('Please select the line plot.');
  13.     exit;
  14.   end;
  15.   Duplicate('Particles');
  16.   i:=0;
  17.   SetForegroundColor(0);
  18.   SetLineWidth(1);
  19.   repeat
  20.     MoveTo(i,0);
  21.     LineTo(i,height);
  22.     i:=i+2;
  23.   until i>width;
  24.   RotateRight(true);
  25.   MeasureArea(false);
  26.   MeasureDensity(false);
  27.   MeasureXY(true);
  28.   LabelParticles(false);
  29.   SetParticleSize(1,999999);
  30.   InvertY(false);
  31.   AnalyzeParticles;
  32. end;
  33.  
  34.  
  35. macro 'Plot Points [P]';
  36. {
  37. Plots the data points contained in the X and Y results columns. Note
  38. that X and Y are reversed because Analyze Particles scans from top
  39. to bottom, not left to right.
  40. }
  41. var
  42.   xmin,xmax,ymin,ymax,i,xscale,yscale:real;
  43.   width,height,margin,pwidth,pheight:integer;
  44. begin
  45.   margin:=40;
  46.   width:=500;
  47.   height:=300;
  48.   xmin:=999999;
  49.   xmax:=-999999;
  50.   ymin:=999999;
  51.   ymax:=-999999;
  52.   for i:=1 to rCount do begin
  53.     if rX[i]<xmin then xmin:=rX[i];
  54.     if rX[i]>xmax then xmax:=rX[i];
  55.     if rY[i]<ymin then ymin:=rY[i];
  56.     if rY[i]>ymax then ymax:=rY[i];
  57.   end;
  58.   SetNewSize(width,height);
  59.   MakeNewWindow('Plot');
  60.   pwidth:=width-2*margin;
  61.   pheight:=height-2*margin;
  62.   xscale:=pheight/(xmax-xmin);
  63.   yscale:=pwidth/(ymax-ymin);
  64.   SetForeground(255);
  65.   SetBackground(0); 
  66.   MoveTo(margin,margin);
  67.   for i:=1 to rCount do begin
  68.     LineTo(margin+(rY[i]-ymin)*yscale,margin+(rX[i]-xmin)*xscale);
  69.   end;
  70.   MakeRoi(margin,margin,pwidth+1,pheight+2);
  71.   MoveTo(margin,margin);
  72.   LineTo(margin+pwidth,margin);
  73.   MoveTo(margin,margin);
  74.   LineTo(margin,margin+pheight);
  75.   FlipVertical;
  76.   KillRoi;
  77.   SetFont('Geneva');
  78.   SetFontSize(9);
  79.   SetText('Centered');
  80.   MoveTo(margin+4,margin+pheight+12);
  81.   writeln(ymin:1:2);
  82.   MoveTo(margin+pwidth,margin+pheight+12);
  83.   writeln(ymax:1:2);
  84.   SetText('Right Justified');
  85.   MoveTo(margin-2,margin+pheight-5);
  86.   writeln(xmin:1:2);
  87.   MoveTo(margin-2,margin);
  88.   writeln(xmax:1:2);
  89. end;
  90.  
  91.  
  92. macro 'Clear Outside [O]'
  93.  {Outline the line plot with the wand tool and then use this macro to}
  94.  {erase everything else.}
  95. begin
  96.   Copy;
  97.   SelectAll;
  98.   Clear;
  99.   RestoreRoi;
  100.   Paste;
  101.   KillRoi;
  102. end;
  103.  
  104.  
  105.  
  106.  
  107.